Don't set the PC_EXPLICIT flag for unused palette entries, that might have
authorTor Lillqvist <tml@iki.fi>
Sun, 17 Feb 2002 22:03:29 +0000 (22:03 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 17 Feb 2002 22:03:29 +0000 (22:03 +0000)
2002-02-17  Tor Lillqvist  <tml@iki.fi>

* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.

* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/win32/gdkcolor-win32.c
gdk/win32/gdkevents-win32.c

index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index eed75915cea955a572da3b7f9adf534e118f0d42..f49e751759925593db630bd82745919c01651564 100644 (file)
@@ -1,3 +1,22 @@
+2002-02-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
+       PC_EXPLICIT flag for unused palette entries, that might have
+       undesired side effects. Just set them to black. Black is always
+       present in a palette, so having superfluous black entries won't
+       cause any extra allocations from the system palette either when
+       realized.
+
+       * gdk/win32/gdkevents-win32.c
+       (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
+       system visual is static color, i.e. the user has told GDK to use
+       just the 16 static colors. In that case no need to redraw
+       anything, as the colors are static and by definition always
+       correctly mapped in the system palette.
+       (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
+       
+       * gtk/gtk.def: Add new gtkfilesel entry points.
+
 2002-02-17  Matthias Clasen  <maclas@gmx.de>
 
        * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, 
index 528ac67a12ac51fe5281e85c70b1b8e58063a361..2259857c075242a35f2ccf29189f3477643ab44d 100644 (file)
@@ -454,8 +454,11 @@ free_colors (GdkColormap *cmap,
   GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
   gint i;
 #ifdef G_ENABLE_DEBUG
-  gint set_explicit = 0;
+  gint set_black_count = 0;
 #endif
+  gboolean *cleared_entries;
+
+  cleared_entries = g_new0 (gboolean, cmap->size);
 
   /* We don't have to do anything for non-palette devices. */
   
@@ -470,7 +473,10 @@ free_colors (GdkColormap *cmap,
          else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC)
            ; /* Nothing either*/
          else
-           cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE;
+           {
+             cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE;
+             cleared_entries[pixels[i]] = TRUE;
+           }
        }
       for (i = cmapp->current_size - 1; i >= 0; i--)
        if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE)
@@ -484,25 +490,26 @@ free_colors (GdkColormap *cmap,
          else
            cmapp->current_size = i + 1;
        }
+      pe.peRed = pe.peGreen = pe.peBlue = pe.peFlags = 0;
       for (i = 0; i < cmapp->current_size; i++)
        {
-         if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE)
+         if (cleared_entries[i])
            {
-             *(WORD*)&pe = i;
-             pe.peFlags = PC_EXPLICIT;
              if (!SetPaletteEntries (cmapp->hpal, i, 1, &pe))
                WIN32_GDI_FAILED ("SetPaletteEntries");
-             GDK_NOTE (COLORMAP, set_explicit++);
+             GDK_NOTE (COLORMAP, set_black_count++);
            }
        }
 #if 0
       GDK_NOTE (COLORMAP, gdk_win32_print_hpalette (cmapp->hpal));
 #else
-      GDK_NOTE (COLORMAP, (set_explicit > 0 ?
-                          g_print ("free_colors: %d (%d) PC_EXPLICIT\n",
-                                   set_explicit, cmapp->current_size)
+      GDK_NOTE (COLORMAP, (set_black_count > 0 ?
+                          g_print ("free_colors: %d (%d) set to black\n",
+                                   set_black_count, cmapp->current_size)
                           : (void) 0));
 #endif
+      g_free (cleared_entries);
+
       break;
 
     default:
index 98859a1955ff57ca17913c727693a36bc506ea61..47df43ff02888fbf9696cd6eef8ce4423af359d6 100644 (file)
@@ -2732,8 +2732,11 @@ gdk_event_translate (GdkEvent *event,
     case WM_QUERYNEWPALETTE:
       GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_QUERYNEWPALETTE: %p\n",
                                             msg->hwnd));
-      synthesize_expose_events (window);
-      update_colors_counter = 0;
+      if (gdk_visual_get_system ()->type == GDK_VISUAL_PSEUDO_COLOR)
+       {
+         synthesize_expose_events (window);
+         update_colors_counter = 0;
+       }
       *ret_val_flagp = TRUE;
       *ret_valp = FALSE;
       break;
@@ -2744,6 +2747,9 @@ gdk_event_translate (GdkEvent *event,
       *ret_val_flagp = TRUE;
       *ret_valp = FALSE;
 
+      if (gdk_visual_get_system ()->type != GDK_VISUAL_PSEUDO_COLOR)
+       break;
+
       if (msg->hwnd == (HWND) msg->wParam)
        break;